<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Filetype
 *
 * @author Sony
 */
class Multimedia_View_Helper_FileTypeSelect extends Zend_View_Helper_Abstract {

    const EOL = "\n";

    public function fileTypeSelect($attributes = array()) {

        $selectedId = isset($attributes['selected']) ? $attributes['selected'] : null;
        $disableId = isset($attributes['disable']) ? $attributes['disable'] : null;
        $config = Tomato_Module_Config::getConfig('upload');
        $config = $config->toArray();
        $fileTypes = $config['extensions'];
        if ($fileTypes) {
            $output = sprintf("<select name='%s' id='%s' >", $attributes['name'], $attributes['id']) . self::EOL
				. '<option value="0">---</option>' . self::EOL;
            foreach ($fileTypes as $fileType => $fileExt) {
                $selected = ($selectedId == null || $selectedId != $fileType) ? '' : ' selected="selected"';
                $disable = ($disableId == null || $disableId != $fileType) ? '' : ' disabled';
                $output .= sprintf('<option value="%s"%s%s>%s</option>', $fileType, $selected, $disable, ucfirst($fileType)) . self::EOL;
            }
            $output .= '</select>' . self::EOL;
            return $output;
        }
        return '';
    }

}

?>
